/*
 *   Copyright 2009 Sukharev Eduard <kraplax@mail.ru>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef NULLBYTEENGINE_H
#define NULLBYTEENGINE_H
 
#include <Plasma/DataEngine>

#include <QHttp>
 
/**
 * @brief DataEngine to manage updates from 0byte-based sites.

 * This engine provides data retrieved from sites, that are
 * based on 0byte site engine. Provides "Posts" and "Comments" sources.
 * Uses QJson library and PostItem and CommentItem classes to parse,
 * manage and prepare data.
 */
class NullByteEngine : public Plasma::DataEngine
{
    Q_OBJECT
 
    public:
        /**
        * The constructor for NullByteClass. Has usual input parameters.
        * @param parent pointer to parent QObject for this engine
        * @param args a list of arguments that are passed to this engine (currently unused)
        */
        NullByteEngine(QObject* parent, const QVariantList& args);
        
        QStringList sources() const;
        
    public slots:
        void readData();
        
    protected:
        /**
        * Standard member function. Called when a new source is requested.
        *
        * @param name the name of the source being requested
        */
        bool sourceRequestEvent(const QString& name);

        /**
        * Standard member function. Called when an automatic update
        * is triggered for an existing source.
        *
        * @param source the name of source being updated
        */
        bool updateSourceEvent(const QString& source);
        
        QHttp * httpConnection;
};
 
#endif // NULLBYTEENGINE_H
